package org.tloss.web.editor.utils;

import java.util.List;

import org.tloss.web.editor.database.editors.jdbc.Column;
import org.tloss.web.editor.model.oper.math.EntityColumnOperator;
import org.tloss.web.editor.model.oper.math.MathOperand;

public class ColumnVariable implements Variable {
	private Variable parent;
	private Column column;

	public ColumnVariable(Column column, Variable parent) {
		this.column = column;
		this.parent = parent;
	}

	public List<Variable> getChildren() {
		return null;
	}

	@Override
	public void setChildren(List<Variable> variables) {

	}

	@Override
	public Variable getParent() {
		return parent;
	}

	@Override
	public void setParent(Variable parent) {
		this.parent = parent;
	}

	@Override
	public boolean hasChildren() {
		return false;
	}

	@Override
	public String toString() {
		return column.getColumnName();
	}

	@Override
	public MathOperand convertToMathOperand() {
		EntityColumnOperator operand = new EntityColumnOperator();
		operand.setColumn(column);
		operand.setTable(((EntityVariable) parent).getTable().getTable());
		operand.setName(((EntityVariable) parent).getTable().getName());
		return operand;
	}
}